<section class="panel">
<head>

<link rel="stylesheet" href="<?php echo base_url();?>js/datatables/datatables.css" type="text/css" />
<script src="<?php echo base_url();?>js/jquery.min.js"></script>
<script src="<?php echo base_url();?>js/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript">
/* function filterGlobal () {
    $('#tabel').DataTable().search(
        $('#cari').val()
       
    ).draw();
} */
 

 
$(document).ready(function() {

     oTable = $('#tabel').dataTable();
 
    $('#cari').on( 'keyup click', function () {
        /* filterGlobal(); */
		
		oTable.fnFilter( $(this).val()
		)
		;
    } 
)
;
} );
</script>
	<header class="bg-success panel-heading font-bold">
		History Legalisir
	</header>
	</head>
	<div class="row text-sm wrapper">
		<div class="col-lg-4">
			<div class="input-group">
				<input type="text" class="input-sm form-control" id ="cari" placeholder="cari">
				<span class="input-group-btn">
					<button class="btn btn-sm btn-warning" type="button">Go!</button>
				</span>
			</div>
		</div>
		<div class="col-lg-4">
			<div class="doc-buttons">
				<a href="<?php echo site_url('pengajuan/tambahPermohonan2');?>"><button class="btn btn-sm btn-info"><i class="fa fa-pencil text"></i>
					<span class="text">Permohonan Legalisir</span></button></a>
				<a href="<?php echo site_url('pengajuan/updateBio');?>"><button class="btn btn-sm btn-info"><i class="fa fa-edit text"></i>
					<span class="text">Update Biodata</span></button></a>
			</div>
		</div>		
	</div>
<div class="table-responsive">
	<table class="table table-striped b-t text-sm" id="tabel">
		<thead>
			<tr>
				<th class="th-sortable" data-toggle="class">Kode pengajuan
					<span class="th-sort">
						<i class="fa fa-sort-down text"></i>
						<i class="fa fa-sort-up text-active"></i>
						<i class="fa fa-sort"></i>
					</span>
				</th>
				<th>Tanggal permohonan</th>
				<th>Tanggal pengambilan</th>
				<th>Sekolah</th>
				<th>Lihat</th>
				<th>Status</th>
		  </tr>
		</thead>
		<tbody>
			<?php
				foreach($users as $user)
				{
					switch($user['STATUS'])
					{
						case 1:
							$stat = "BELUM DIVERIFIKASI";
							break;
						case 2:
							$stat = "SEDANG DIVERIFIKASI";
							break;
						case 3:
							$stat = "TERVERIFIKASI";
							break;
					}
					
					if ($user['LEMBAR_TK1'] != '0'){
					if($user['TK1'] != '0'){
					$tk1 = $user['TK1'];
					}
					else
					{
					$tk1 = '';
					}
					}
					else {
					$tk1 = '';
					}
					
					if ($user['LEMBAR_TK2'] != '0'){
					if($user['TK2'] != '0'){
					$tk2 = $user['TK2'];
					}
					else
					{
					$tk2 = '';
					}
					}
					else {
					$tk2 = '';
					}
					
					if ($user['LEMBAR_TK3'] != '0'){
					if($user['TK3'] != '0'){
					$tk3 = $user['TK3'];
					}
					else
					{
					$tk3 = '';
					}
					}
					else {
					$tk3 = '';
					}
					
					
					echo "<tr>";
					echo "<td>$user[ID_PENGAJUAN]</td>";
					echo "<td>$user[TGL_PENGAJUAN]</td>";
					echo "<td>$user[TGL_PENGAMBILAN]</td>";
					
					echo "<td>$tk1$tk2$tk3</td>";
					
					echo "<td><a href=".site_url("pengajuan/lihatPengajuan/$user[ID_PENGAJUAN]").">Lihat</a></td>";
					echo "<td>$stat</td>";
					
					echo "</tr>";
				}
			?>
		</tbody>
	</table>
</div>
<footer class="panel-footer">
<div class="row">
		<div class="col-sm-4 text-left">
			<small class="text-muted inline m-t-sm m-b-sm"><?php
				$itemPerPage = 5;
				$page=1;
				if($_SERVER['QUERY_STRING'] != null){
					$page = explode('=', $_SERVER['QUERY_STRING']);
					$page = $page[1];
				}
				$first = ($itemPerPage * ($page-1)) + 1;
				$last = $first + $itemPerPage - 1;
				if($last > $total)
					$last = $total;
				echo "showing $first-$last of $total items";
			?></small>
		</div>
		<div class="col-sm-4 text-right text-center-xs pull-right">                
			<ul class="pagination pagination-sm m-t-none m-b-none">
				<li><a href="<?php
					$page=1;
					if($_SERVER['QUERY_STRING'] != null){
						$page = explode('=', $_SERVER['QUERY_STRING']);
						$page = $page[1];
					}
					if($page > 1){
						$page--;
						echo "?page=$page";
					}
					else
						echo "#";
				?>"><i class="fa fa-chevron-left"></i></a></li>
				<?php
					$pages = ceil($total/$itemPerPage);
					for($i = 1; $i <= $pages; $i++){
						echo "<li><a href=?page=$i>$i</a></li>";
					}
				?>
				<li><a href="<?php
					$page=1;
					if($_SERVER['QUERY_STRING'] != null){
						$page = explode('=', $_SERVER['QUERY_STRING']);
						$page = $page[1];
					}
					if($page < ceil($total/$itemPerPage)){
						$page++;
						echo "?page=$page";
					}
					else
						echo "#";
				?>"><i class="fa fa-chevron-right"></i></a></li>
			</ul>
		</div>
	</div>
</footer>
</section>